from django.db import models
from datetime import datetime
from django.utils import timezone

class Base(models.Model):
	#创建时间
	create_time = models.DateTimeField(default=timezone.now(),null=True)

	class Meta:
		abstract = True

# 用户类
class User(Base):
	username = models.CharField(max_length=200)
	password = models.CharField(max_length=200)
	img = models.CharField(max_length=200)
	type = models.IntegerField()  # 0普通   1管理

	class Meta:
		db_table = "user"

# 幻灯片表
class Pics(Base):

	# 名称
	title = models.CharField(max_length=200)
	# 图片链接
	link = models.CharField(max_length=200)
	#图片
	image = models.CharField(max_length=200)
	class Meta:
		db_table = 'pics'

# 分类表
class Cate(Base):
	# 名称
	name = models.CharField(max_length=200)
	# 父id
	pid = models.IntegerField()

	class Meta:
		db_table = 'cate'


class Goods(Base):
	# 名称
	name = models.CharField(max_length=200)
	#简介
	desc = models.CharField(max_length=500)
	# 规格
	params = models.CharField(max_length=500)
	#商品图片
	img = models.CharField(max_length=200,null=True)
	#商品视频
	video = models.CharField(max_length=200,null=True)
	# 商品价格
	price = models.IntegerField()   # 分
	#关注数w
	flow = models.IntegerField(default=0,null=True)
	#分类
	cate_id = models.IntegerField()

	class Meta:
		db_table = 'goods'

# 评论表
class Comment(Base):
	# 内容
	content = models.CharField(max_length=500)
	# 谁评论的
	uid = models.IntegerField()
	# 评论的商品
	gid = models.IntegerField()

	class Meta:
		db_table = 'comment'


# 关注表
class UserFlow(Base):

	# 谁关住的
	uid = models.IntegerField()
	gid = models.IntegerField()

	class Meta:
		db_table = 'userflow'



